<?php


require_once 'AipSpeech.php';

// 你的 APPID AK SK
const APP_ID = '11431596';
const API_KEY = 'fB2qofpsggG97SCNi6NOkqLU';
const SECRET_KEY = 'Phqi0Gmq4NeHnjgQFcw7C3YoUnbDv9Df ';

$client = new AipSpeech(APP_ID, API_KEY, SECRET_KEY);
$content = $_POST['content'];
$pit = $_POST['pit']?$_POST['pit']:4;
$per = $_POST['per']?$_POST['per']:5;

$result = $client->synthesis($content, 'zh', 1, array('pit'=>$pit,'per'=>$per,
    'vol' => 15,
));

// 识别正确返回语音二进制 错误则返回json 参照下面错误码
if(!is_array($result)){
    file_put_contents('audio.mp3', $result);
}else{
	dump($result);
}